package com.example.fileserver_API.Controller.Upload;

import com.example.fileserver_API.Entity.VO.APIResult;
import com.example.fileserver_API.Interfaces.IService.IUploadService;
import com.example.fileserver_API.utils.APIResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;

@RestController
@RequestMapping("/API/Upload")
@CrossOrigin
public class UploadController {
    @Autowired
    IUploadService _IUploadServicel;

    /**
     * 普通的上传图片
     * @param file 文件
     * @return APIResult
     */
    @PostMapping("")
    public APIResult Upload(@RequestParam("file") MultipartFile file, HttpServletRequest req){
        return _IUploadServicel.Upload(file,req);
    }

    /**
     * 上传用户头像
     * @param file 文件
     * @param req req
     * @return APIResult
     */
    @PostMapping("/UploadUser")
    public APIResult UploadUser(@RequestParam("file") MultipartFile file, HttpServletRequest req){
        return _IUploadServicel.UploadUser(file,req);
    }

    /**
     * 带水印的上传
     * @param file 文件
     * @return @Override
     */
    @PostMapping("/Uploadwatermark")
    public APIResult Uploadwatermark(@RequestParam("file") MultipartFile file,HttpServletRequest req){
        return _IUploadServicel.Uploadwatermark(file,req);
    }

    /**
     * 上传资源
     * @param file 资源文件
     * @return @Override
     */
    @PostMapping("/UploadResoure")
    public APIResult UploadResoure(@RequestParam("file") MultipartFile file,HttpServletRequest req){
        return _IUploadServicel.UploadResoure(file,req);
    }

    /**
     * 上传app文件
     * @param file app文件
     * @return APIResult
     */
    @PostMapping("/UploadAppFile")
    public APIResult UploadAppFile(@RequestParam("file") MultipartFile file){
        return _IUploadServicel.UploadAppFile(file);
    }

    /**
     * 上传视频
     * @param videoFile 视频文件
     * @return APIResult
     */
    @PostMapping("/uploadVideo")
    public APIResult handleVideoUpload(@RequestParam("file") MultipartFile videoFile) {
        return _IUploadServicel.handleVideoUpload(videoFile);
    }

}
